package com.a.learning_keep.activity.game

import android.graphics.Bitmap
import android.webkit.WebView
import android.webkit.WebViewClient
import com.a.learning_keep.base.BaseActivity
import com.a.learning_keep.databinding.ActivityGameBinding

class GameActivity : BaseActivity<ActivityGameBinding>() {
    override fun getBind(): ActivityGameBinding {
        return ActivityGameBinding.inflate(layoutInflater)
    }

    override fun initView() {
        var webView = binding.webview
        // 启用 JavaScript 支持
        webView.settings.javaScriptEnabled = true

        // 允许缩放
        webView.settings.setSupportZoom(true)
        webView.settings.builtInZoomControls = true
        webView.settings.displayZoomControls = false

        // 设置 Web 视图客户端
        webView.webViewClient = MyWebViewClient()

        // 加载网页
        webView.loadUrl("baidu.com")

    }

    // Web 视图客户端
    private inner class MyWebViewClient : WebViewClient() {
        override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
            // 显示进度条
        }

        override fun onPageFinished(view: WebView?, url: String?) {
            // 隐藏进度条
        }
    }

}